package com.muy.redis.common.dialog;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.LoadingDecorator;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.ui.JBColor;
import com.intellij.ui.NumberDocument;
import com.intellij.util.ui.JBUI;
import com.muy.redis.utils.RedisPoolManager;
import com.muy.redis.utils.ThreadPoolManager;
import com.muy.redis.view.window.redis.MrRedisTree;
import com.muy.redis.view.window.redis.bean.MrRedisConnectionParam;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.util.function.Function;

/**
 * @Author jiyanghuang
 * @Date 2023/9/16 11:29
 */
public class MrRedisConfirmDialog implements DialogFormMark, Disposable {

    private String centerPanelText;
    private String title;
    private Project project;
    private Function<MrRedisConfirmDialog, Pair<Boolean, String>> okFun;

    public MrRedisConfirmDialog(String centerPanelText, String title, Project project, Function<MrRedisConfirmDialog, Pair<Boolean, String>> okFun) {
        this.centerPanelText = centerPanelText;
        this.title = title;
        this.project = project;
        this.okFun = okFun;
    }

    /**
     * if connectionId is blank ? New Connection : Edit Connection
     *
     * @param project
     * @param connection
     * @param connectionTree
     */


    @Override
    public JComponent jComponent() {
        JLabel jLabel = new JLabel(centerPanelText);
        jLabel.setBorder(new EmptyBorder(10, 0, 10, 0));
        return jLabel;
    }

    @Override
    public <T extends DialogFormMark> Function<T, Pair<Boolean, String>> okFun() {
        return (Function<T, Pair<Boolean, String>>) okFun;
    }

    @Override
    public String title() {
        return title;
    }

    @Override
    public Project getProject() {
        return project;
    }

    @Override
    public void dispose() {

    }
}
